package com.lanou.service.login;

import com.lanou.bean.LoginResultBean;
import com.lanou.bean.UserBean;
import com.lanou.mapper.logindao.LoginMapper;
import org.apache.ibatis.annotations.Param;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;

/**
 * Created by dllo on 18/2/26.
 */
@Component
public class LoginServiceImpl implements LoginService {
   @Resource
    LoginMapper loginMapper;

    @Override
    public LoginResultBean login(String name, String password) {
        UserBean userBean = loginMapper.login(name, password);
        LoginResultBean loginResultBean = new LoginResultBean();
        if (userBean == null){
            System.out.println(userBean);
            loginResultBean.setStatue("登录失败,用户名或者密码错误");
            loginResultBean.setResult(false);
        }else {
            System.out.println(userBean);
            loginResultBean.setStatue("登录成功");
            loginResultBean.setResult(true);
            loginResultBean.setUser(userBean);
        }
        return loginResultBean;
    }

}
